package com.bdqn.rabbitmqporducer1.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

//@Configuration
public class FanoutConfig {
    @Bean
    public Queue queueFirst() {
        return new Queue("fanout.First");
    }

    @Bean
    public Queue queueSecond() {
        return new Queue("fanout.Second");
    }

    @Bean
    public Queue queueThird() {
        return new Queue("fanout.Third");
    }

    @Bean
    FanoutExchange fanoutExchange() {
        return new FanoutExchange("fanoutExchange");
    }

    @Bean
    Binding bindingExchangeFirst() {
        return BindingBuilder.bind(queueFirst()).to(fanoutExchange());
    }

    @Bean
    Binding bindingExchangeSecond() {
        return BindingBuilder.bind(queueSecond()).to(fanoutExchange());
    }

    @Bean
    Binding bindingExchangeThird() {
        return BindingBuilder.bind(queueThird()).to(fanoutExchange());
    }

    @Bean
    public Queue queueFourth() {
        return new Queue("fanout.Fourth");
    }
    @Bean
    MessageConverter messageConverter() {
        return new Jackson2JsonMessageConverter();
    }
}
